package com.xntv.service;

import com.sun.istack.internal.NotNull;
import com.xntv.fast.pojo.Column;
import com.xntv.fast.pojo.Model;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

/**
 *
 *
 */
@Service
public class ModelService {

    @Resource
    private ColumnService columnService;

    public List<Model> getModels() {
        List<Column> columns = columnService.getColumns();
        return columns.stream().map(this::exchange).collect(Collectors.toList());
    }

    private Model exchange(@NotNull Column column) {
        return Model.builder()
                .Id(column.getColumnId())
                .name(column.getColumnName())
                .pId(column.getColumnPId())
                .build();
    }
}
